package org.ch01.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 编写 Servlet 的四个步骤：
 * 第一：继承 HttpServlet
 * 第二：重写 doXxx 方法
 * 第三：编辑 doXxx 方法，实现具体的业务逻辑功能
 * 第四：定义访问路径
 *
 * @author zqx
 * @date 2024-06-06
 */
@WebServlet("/hello.do")
public class HelloWorldServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        PrintWriter out = resp.getWriter();
        out.write("Hello,World");
        out.flush();
        out.close();
    }
}
